package main

import (
	"fmt"
)

type Uintreg uint64

const MaxUintptr = ^uintptr(0)
const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const
const RegSize = 4 << (^Uintreg(0) >> 63) // unsafe.Sizeof(uintreg(0)) but an ideal const
const maxAlign = 8

//const hchanSize = unsafe.Sizeof(runtime.hchan{}) + uintptr(-int(unsafe.Sizeof(runtime.hchan{}))&(maxAlign-1))

// alignUp rounds n up to a multiple of a. a must be a power of 2.
func alignUp(n, a uintptr) uintptr {
	return (n + a - 1) &^ (a - 1)
}

func main() {
	fmt.Println("MaxUintptr:", MaxUintptr)
	fmt.Println("(^uintptr(0) >> 63) :", (^uintptr(0) >> 63))
	fmt.Println("PtrSize:", PtrSize)
	fmt.Println("RegSize:", RegSize)
	tt := 1 << (4 * PtrSize)
	fmt.Println("1<<(4*PtrSize):", tt)
	//fmt.Println("hchanSize:", hchanSize)
	fmt.Println("uintptr(16):", uintptr(16))
	fmt.Println("alignUp(3,16):", alignUp(3, 16))
	fmt.Println("alignUp(16,16):", alignUp(16, 16))
	fmt.Println("alignUp(18,16):", alignUp(18, 16))

}
